// pages/home/home.js
import {Home} from 'home-model.js';

var home = new Home();

Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  onLoad:function(){
    this._loadDate();
  },

  _loadDate:function(){
    var id = 1;

    home.getBannerData(id, (res) => {
      this.setData({
        'bannerArr': res,
      });
    });

    home.getThemeData((data) => {
      this.setData({
        'themeArr': data,
      });
    });

    home.getProductsData((data) => {
      this.setData({
        'productsArr': data,
      });
    });
    
  },

  // 商品详情参数传递
  onProductsItemTap:function(event){
    var id = home.getDataSet(event,'id');
    wx.navigateTo({
      url: '../product/product?id=' + id,
    })
  },

  // 商品详情参数传递
  onThemesItemTap: function (event) {
    var id = home.getDataSet(event, 'id');
    var name = home.getDataSet(event, 'name');
    wx.navigateTo({
      url: '../theme/theme?id=' + id + '&name=' + name,
    })
  }

})